<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-remove"></li></button>
	<h5 class="modal-title">新增用户</h5>
</div>

<div class="modal-body">

	<form id="user-form" name="user-form" class="form-horizontal">
		<input type="hidden" name="id">
		<input type="hidden" name="version">
		<input type="hidden" name="isSuperAdmin">
		<input type="hidden" name="createDateTime" data-flag="date" data-format="yyyy-MM-dd HH:mm:ss">
		<input type="hidden" name="deleted">
		<input type='hidden' value='${CSRFToken}' id='csrftoken'>
		<div class="box-body">
			<div class="col-md-6">
				<div class="form-group">
					<label for="loginName" class="col-sm-3 control-label">用户名(*)</label>

					<div class="col-sm-8">
						<input type="text" class="form-control" id="userName" name="userName" placeholder="用户名(*)">
					</div>
				</div>
				<div class="form-group">
					<label for="email" class="col-sm-3 control-label">Email(*)</label>

					<div class="col-sm-8">
						<input type="text" class="form-control" id="email" name="email" placeholder="Email(*)">
					</div>
				</div>
				<div class="form-group">
					<label for="name" class="col-sm-3 control-label">真实姓名</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="nickName" name="nickName" placeholder="姓名">
					</div>
				</div>
				<div class="form-group">
					<label for="telphone" class="col-sm-3 control-label">初始密码</label>

					<div class="col-sm-8">
						<input type="password" class="form-control" id="pas" name="pas" placeholder="初始密码">
					</div>
				</div>

			</div>
			<div class="col-md-6">
				<div class="form-group">
					<label for="telphone" class="col-sm-3 control-label">手机号</label>

					<div class="col-sm-8">
						<input type="text" class="form-control" id="phone" name="phone" placeholder="手机号">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">籍贯</label>
					<div class="col-sm-8">
						<select name="address" class="form-control" id="address">
							<option value="北京市">北京市</option>
							<option value="上海市">上海市</option>
							<option value="天津市">天津市</option>
							<option value="重庆市">重庆市</option>
							<option value="黑龙江省">黑龙江省</option>
							<option value="辽宁省">辽宁省</option>
							<option value="吉林省">吉林省</option>
							<option value="河北省">河北省</option>
							<option value="山东省">山东省</option>
							<option value="山西省">山西省</option>
							<option value="陕西省">陕西省</option>
							<option value="甘肃省">甘肃省</option>
							<option value="青海省">青海省</option>
							<option value="河南省">河南省</option>
							<option value="安徽省">安徽省</option>
							<option value="湖北省">湖北省</option>
							<option value="湖南省">湖南省</option>
							<option value="江苏省">江苏省</option>
							<option value="浙江省">浙江省</option>
							<option value="江西省">江西省</option>
							<option value="福建省">福建省</option>
							<option value="广东省">广东省</option>
							<option value="海南省">海南省</option>
							<option value="台湾省">台湾省</option>
							<option value="四川省">四川省</option>
							<option value="云南省">云南省</option>
							<option value="贵州省">贵州省</option>
							<option value="内蒙古自治区">内蒙古自治区</option>
							<option value="宁夏回族自治区">宁夏回族自治区</option>
							<option value="新疆维吾尔族自治区">新疆维吾尔族自治区</option>
							<option value="西藏自治区">西藏自治区</option>
							<option value="北广西壮族自治区">广西壮族自治区</option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">性别</label>

					<div class="col-sm-8">
						<select name="sex" class="form-control" id="sex">
							<option value="0">男</option>
							<option value="1">女</option>
						</select>
					</div>

				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">年龄</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="age" name="age" placeholder="年龄">
					</div>
				</div>
			</div>
		</div>
		<!-- /.box-body -->
		<div class="box-footer text-right">
			<!--以下两种方式提交验证,根据所需选择-->
			<button type="button" class="btn btn-default" data-btn-type="cancel" data-dismiss="modal">取消</button>
			<button type="button" class="btn btn-primary" data-btn-type="save">提交</button>
		</div>
		<!-- /.box-footer -->
	</form>

</div>
<script>
	$(function() {
		$(".btn-primary").click(function() {
			//			console.log($("#userName").val());
			$.ajax({
				type: "post",
				url: "/user/add",
				data: {
					username: $("#userName").val(),
					email: $("#email").val(),
					nickname: $("#nickName").val(),
					pas: $("#pas").val(),
					phone: $("#phone").val(),
					address: $("#address").val(),
					sex: $("#sex").val(),
					age: $("#age").val()
				},
				success: function(data) {
					data = JSON.parse(data);
					console.log(data);
					if(data.code == 2) {
						alert("添加成功");
						location.href = "/user/list";

					} else {
						alert(data.message);
					}
				},
				error: function(er) {
					console.log(er);
				}
			});
		});
	});
</script>